<template>
	<view>
		<u-navbar title="去完成" :autoBack="true" :placeholder="true"></u-navbar>
		<!-- 上传 -->
		<view class="update_box flexC">
			<ImgUpload @callback="callbackImg" imgUrl="http://qiniu.suboshimuying.cn/static/merchant/ic_update.png" />
		</view>
		<!-- 按钮 -->
		<view class="btn_box flexC" @click="finshOrder">确认完成</view>
	</view>
</template>

<script>
	import ImgUpload from '@/components/ImgUpload/ImgUpload.vue'
	export default {
		components: {
			ImgUpload
		},
		data() {
			return {
				form: {
					order_id: null, //订单id
					image: "", //
				},
				imgList: []
			};
		},
		onLoad(option) {
			this.form.order_id = option.id
		},
		methods: {
			callbackImg(e) {
				this.imgList = e
				console.log(e);
			},
			async finshOrder() {
				if (this.imgList.length !== 0) {
					this.form.image = this.imgList.map(item => item.url).join(',')
					let {
						code,
						msg
					} = await this.$api.finshOrder(this.form)
					// console.log(res);
					uni.$u.toast(msg)
					if (code === 1) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					}
				} else {
					uni.$u.toast('请上传图片')
				}

			}
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.update_box {
		margin: 100rpx auto 334rpx;
	}

	.btn_box {
		margin: 0 auto;
		width: 686rpx;
		height: 88rpx;
		border-radius: 600rpx;
		opacity: 1;
		background: linear-gradient(131.2deg, rgba(179, 142, 255, 1) 0%, rgba(130, 111, 255, 1) 100%);
		color: rgba(255, 255, 255, 1);
		font-size: 32rpx;
		font-weight: 700;
	}
</style>
